home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / gofer221.zip / SQUIGOL < prev    next >
Text File  |  1991-11-20  |  1KB  |  31 lines

  1. -- A couple of examples defining an ascii form of squigol notation for Gofer:
  2. -- All of these are of course just different syntax for standard prelude
  3. -- functions:
  4.  
  5. infixr  5  **,   <|,   <-/-,  -/->,  -//->
  6.  
  7. f ** xs  =  [ f x | x<-xs ]             -- map
  8. p <| xs  =  [ x | x<-xs, p x ]          -- filter
  9.  
  10. (a <-/- f) []     = a                   -- foldr
  11. (a <-/- f) (x:xs) = f x ((a <-/- f) xs)
  12.  
  13. (f -/-> a) []     = a                   -- foldl
  14. (f -/-> a) (x:xs) = (f -/-> f a x) xs
  15.  
  16. (f -//-> a) xs    = a : (case xs of     -- scanl
  17.                          []     -> []
  18.                          (x:xs) -> (f -//-> f a x) xs)
  19.  
  20. -- Here's another piece of notation -- not squigol, but of a similar flavour
  21. -- which would enable us to do away with the zipWith family of functions:
  22. --
  23. -- map f xs1 << xs2 << ... << xsn  = zipWithn f xs1 xs2 ... xsn
  24. --
  25. -- in terms of the old notation, (<<) = zipWith (\f x->f x)
  26.  
  27. infixl 0 <<
  28.  
  29. f:fs << x:xs  = f x : (fs << xs)
  30. _    << _     = []
  31.